/****************************************************
文件：UI.cs
作者：UnitySir
邮箱：zouajck@foxmail.com
日期：2021/05/02 16:13:59
功能：Nothing
*****************************************************/

using System;
using System.Collections;
using System.Collections.Generic;
using DSFramework;
using UnityEngine;

public static class UI<T> where T : DSViewBase, new()
{
    private static Dictionary<string, GameObject> UIDic = new Dictionary<string, GameObject>();
    static string name = typeof(T).Name;

    public static void ShowUI(GameObject viewObj)
    {
        if (UIDic.ContainsKey(name))
        {
            viewObj.Show();
        }
        else
        {
            UIDic.Add(name, viewObj);
            viewObj.Show();
        }
    }

    public static void HideUI(GameObject viewObj)
    {
        if (UIDic.ContainsKey(name))
        {
            viewObj.Hide();
        }
    }

    public static void DestroyUI(GameObject viewObj)
    {
        if (UIDic.ContainsKey(name))
        {
            UIDic.Remove(name);
            viewObj.Destroy();
            GC.Collect();
        }
    }
}